from tortoise import fields
from app.models.base import BaseModel

class RequestLog(BaseModel):
    """请求日志模型"""
    user_id = fields.IntField(null=True, description="用户ID")
    username = fields.CharField(max_length=50, null=True, description="用户名")
    ip_address = fields.CharField(max_length=50, description="IP地址")
    method = fields.CharField(max_length=10, description="请求方法")
    path = fields.CharField(max_length=200, description="请求路径")
    status_code = fields.IntField(description="状态码")
    response_time = fields.FloatField(description="响应时间(ms)")
    user_agent = fields.TextField(null=True, description="用户代理")
    request_body = fields.TextField(null=True, description="请求体")
    response_body = fields.TextField(null=True, description="响应体")
    
    class Meta:
        table = "request_logs"
        table_description = "请求日志表"

class LoginHistory(BaseModel):
    """登录历史模型"""
    user_id = fields.IntField(description="用户ID")
    username = fields.CharField(max_length=50, description="用户名")
    ip_address = fields.CharField(max_length=50, description="IP地址")
    user_agent = fields.TextField(null=True, description="用户代理")
    login_status = fields.BooleanField(description="登录状态：True-成功，False-失败")
    login_message = fields.CharField(max_length=200, null=True, description="登录消息")
    
    class Meta:
        table = "login_history"
        table_description = "登录历史表"